'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')
const fs = require('fs')
var configObj = {
  dev: {
    // Paths
    assetsPublicPathBase: '/', //生产环境下静态根路径
    resourcesPath: 'resources', //本地静态资源copy到构建子目录中，or 大字体，大图片，大文件构建到的目录
    assetsSubDirectory: '',
    assetsPublicPath: '/', //为了线上配置的目录/resources/，如果线上是根目录，则替换为 /
    proxyTable: {
      '/api': {
        // target: 'https://next.xuetangonline.com/', //旗舰测试地址
        target: 'https://xt.yuketang.cn/', //雨课堂测试地址       
        // target: 'http://192.168.105.121:8008/',
        //target:"http://apimock.xuetangx.com/mock/619",
        // target: 'http://192.168.120.57:9000/',
        // target: 'http://192.168.120.211:8000/',
        // target:'http://192.168.105.218:9999',
        // target: 'http://192.168.104.132:8008',
        // target: 'https://next.xuetangx.com',
        // target: 'https://pre-apple-www.xuetangonline.com',
        changeOrigin: true
      },
      '/video-log':{
        // target: 'http://10.0.0.199:9005',//旗舰测试地址
        target: 'https://xt.yuketang.cn', //雨课堂测试地址
        //target:"http://apimock.xuetangx.com/mock/619",
        changeOrigin: true
      },
      '/sunchi':{
        target: 'http://10.0.3.3:8787',
        changeOrigin: true,
        pathRewrite: {
          '^/lalala': '/'
        }
      }
    },

    // Various Dev Server settings
    host: '0.0.0.0', // can be overwritten by process.env.HOST
    port: 8000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-


    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },

  build: {
    // Template for index.html
    // app: path.resolve(__dirname, '../dist/app.html'),
    // course: path.resolve(__dirname, '../dist/course.html'),
    // live: path.resolve(__dirname, '../dist/live.html'),
    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsPublicPathBase: '/', //生产环境下静态根路径
    resourcesPath: 'resources', //本地静态资源copy到构建子目录中，or 大字体，大图片，大文件构建到的目录
    assetsSubDirectory: '', //为了线上配置的目录，build时把资源文件放到resources目录，上线时项目有前缀目录时，变成''
    assetsPublicPath: '/',

    /**
     * Source Maps
     */

    productionSourceMap: true,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: 'source-map',


    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: false
  }
}

//遍历出所有根目录下的xxxx.html页面
var rootPath = path.join(__dirname, "../");
var files = fs.readdirSync(rootPath);
files.forEach(function(file, index) {
    var curPath = rootPath + file;
    if (!fs.statSync(curPath).isDirectory() && /^.*\.html$/gi.test(file)) {
        var htmlName = file.replace(/\.html/, "");
        configObj.build[htmlName] = path.resolve(__dirname, '../dist/' + htmlName + '.html');
    }
});

module.exports = configObj;
